// By Tony Chi at 2011-05-27

console.log('injected.js');

$(document).ready(function(){
    $('body').append(
    '<div id="__photo">' + 
        '<div id="__inner"> ' +
            '<div id="__bar">' +
                //'<span>Hello world!</span><br />' +
                '<img src="chrome-extension://__MSG_@@extension_id__/images/icon_128.png" />' +
            '</div>' +
            '<div id="__list">' + 
                '<div id="__list_filter">' + 
                    '<input id="__list_filter_text" type="search" />' + 
                '</div>' +
                '<div id="__list_images_container">' +
                    '<div id="__list_images"></div>' +
                    '<div id="__list_images_preivew"></div>' +
                '</div>' +
            '</div>' + 
        '</div>' +
    '</div>');

    $('img').clone()
        .removeAttr('style')
        .removeAttr('alt')
        .aeImageResize({ height: 50, width: 50 })
        .click(function(){
                $('#__list_images_preivew').empty()
                    .append($(this).clone()
                                .removeAttr('width').removeAttr('height')
                                .aeImageResize(430, 430));
        })
        .appendTo($('#__list_images'));

    //console.log($('img:not(#__photo>img)').clone().aeImageResize({ height: 50, width: 50 }).html());

    $('#__bar').click(function() {
        $('#__list').toggle();
    });
    $('#__bar img').attr('src', chrome.extension.getURL('images/icon_48.png'));
    $('#__list').toggle();
    $('#__photo').floatBar({ "top": 5, "sideOffset": 5 });
});
